package com.login.dao;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.orm.ibatis.SqlMapClientTemplate;

public class LoginDaoImpl implements ILoginDao {
	public static Logger log = Logger.getLogger(LoginDaoImpl.class);
	private SqlMapClientTemplate sqlMapClienet;


	public int isLegalUser(String user, String password) {
		int resultNum =0;
		Object obj=null;
		try
		{
			obj = sqlMapClienet.queryForObject("loginResult", user, password);
			 
		}
		catch(Exception e)
		{
			log.info("查询用户信息失败", e);
		}
		// TODO Auto-generated method stub
		if (obj == null) {
			return 0;
		}
		return (Integer) obj;	}
	
	/**
	 * 理财对象框初始化
	 */
	public List<List<Map>> managingFinancialInit()
	{
		List<String> list = new ArrayList<String>();
		List<List<Map>> resultList = new ArrayList<List<Map>>();
		List<Map> listMap = null;
		list.add("managingFinancialObj");
		list.add("managingFinancialWay");
		list.add("managingFinancialMoney");
		list.add("managingFinancialTime");
		for(String string:list)
		{
			listMap = new ArrayList<Map>();
			try
			{
			listMap = sqlMapClienet.queryForList(string);
			}
			catch(Exception e)
			{
				log.info("查询理财下拉框信息失败", e);
			}
			resultList.add(listMap);
			
		}
		return resultList;
		
	}


	public SqlMapClientTemplate getSqlMapClienet() {
		return sqlMapClienet;
	}


	public void setSqlMapClienet(SqlMapClientTemplate sqlMapClienet) {
		this.sqlMapClienet = sqlMapClienet;
	}
	
	

}
